package com.intelligent.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

/**
 * 待对账客户信息表
 * @TableName customer_info
 */
@TableName(value ="customer_info")
@Data
public class CustomerInfo implements Serializable {
    /**
     * 自增主键
     */
    @TableId(type = IdType.AUTO)
    private Integer id;

    /**
     * 客户名称
     */
    private Long customerId;

    /**
     * 联系人
     */
    private Integer uId;

    /**
     * 对账周期
     */
    private String reconciliationCycle;

    /**
     * 账单创建日
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")

    private Date creationDate;

    /**
     * 下次对账日
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")

    private Date nextReconciliationDate;

    /**
     * 应收总额
     */
    private BigDecimal totalReceivables;

    /**
     * 已收总额
     */
    private BigDecimal totalAmountReceived;

    /**
     * 待收总额
     */
    private BigDecimal totalAmountCollected;

    /**
     * 已退总额
     */
    private BigDecimal refundedTotal;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        CustomerInfo other = (CustomerInfo) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getCustomerId() == null ? other.getCustomerId() == null : this.getCustomerId().equals(other.getCustomerId()))
            && (this.getUId() == null ? other.getUId() == null : this.getUId().equals(other.getUId()))
            && (this.getReconciliationCycle() == null ? other.getReconciliationCycle() == null : this.getReconciliationCycle().equals(other.getReconciliationCycle()))
            && (this.getCreationDate() == null ? other.getCreationDate() == null : this.getCreationDate().equals(other.getCreationDate()))
            && (this.getNextReconciliationDate() == null ? other.getNextReconciliationDate() == null : this.getNextReconciliationDate().equals(other.getNextReconciliationDate()))
            && (this.getTotalReceivables() == null ? other.getTotalReceivables() == null : this.getTotalReceivables().equals(other.getTotalReceivables()))
            && (this.getTotalAmountReceived() == null ? other.getTotalAmountReceived() == null : this.getTotalAmountReceived().equals(other.getTotalAmountReceived()))
            && (this.getTotalAmountCollected() == null ? other.getTotalAmountCollected() == null : this.getTotalAmountCollected().equals(other.getTotalAmountCollected()))
            && (this.getRefundedTotal() == null ? other.getRefundedTotal() == null : this.getRefundedTotal().equals(other.getRefundedTotal()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getCustomerId() == null) ? 0 : getCustomerId().hashCode());
        result = prime * result + ((getUId() == null) ? 0 : getUId().hashCode());
        result = prime * result + ((getReconciliationCycle() == null) ? 0 : getReconciliationCycle().hashCode());
        result = prime * result + ((getCreationDate() == null) ? 0 : getCreationDate().hashCode());
        result = prime * result + ((getNextReconciliationDate() == null) ? 0 : getNextReconciliationDate().hashCode());
        result = prime * result + ((getTotalReceivables() == null) ? 0 : getTotalReceivables().hashCode());
        result = prime * result + ((getTotalAmountReceived() == null) ? 0 : getTotalAmountReceived().hashCode());
        result = prime * result + ((getTotalAmountCollected() == null) ? 0 : getTotalAmountCollected().hashCode());
        result = prime * result + ((getRefundedTotal() == null) ? 0 : getRefundedTotal().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", customerId=").append(customerId);
        sb.append(", uId=").append(uId);
        sb.append(", reconciliationCycle=").append(reconciliationCycle);
        sb.append(", creationDate=").append(creationDate);
        sb.append(", nextReconciliationDate=").append(nextReconciliationDate);
        sb.append(", totalReceivables=").append(totalReceivables);
        sb.append(", totalAmountReceived=").append(totalAmountReceived);
        sb.append(", totalAmountCollected=").append(totalAmountCollected);
        sb.append(", refundedTotal=").append(refundedTotal);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}
